﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ZEFIT
{
    public partial class MainForm : Form
    {
        private LoginForm loginForm = null;
        public User user = null;

        public MainForm(LoginForm loginForm, User user)
        {
            this.loginForm = loginForm;
            this.user = user;
            InitializeComponent();
            lbl_username.Text = "Hallo " + user.UserName;
            if (user.IsAdmin == false)
            {
                btn_categories.Enabled = false;
                btn_users.Enabled = false;
            }
        }

        private void btn_categories_Click(object sender, EventArgs e)
        {
            CategoriesForm categorieForm = new CategoriesForm(this);
            categorieForm.Visible = true;
            this.Visible = false;
            categorieForm.Show();
        }

        private void btn_customers_Click(object sender, EventArgs e)
        {
            CustomersForm customerForm = new CustomersForm(this);
            customerForm.Visible = true;
            this.Visible = false;
            customerForm.Show();
        }

        private void btn_projects_Click(object sender, EventArgs e)
        {
            ProjectsForm projectForm = new ProjectsForm(this);
            projectForm.Visible = true;
            this.Visible = false;
            projectForm.Show();
        }

        private void btn_rapports_Click(object sender, EventArgs e)
        {
            RapportsForm rapportForm = new RapportsForm(this);
            rapportForm.Visible = true;
            this.Visible = false;
            rapportForm.Show();
        }

        private void btn_users_Click(object sender, EventArgs e)
        {
            UsersForm usersForm = new UsersForm(this);
            usersForm.Visible = true;
            this.Visible = false;
            usersForm.Show();
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            loginForm.logout();
        }

        public void openForm()
        {
            this.Visible = true;
        }
    }
}
